from typing import Any, Dict, Optional, Union
from app.utils.timezone_util import get_current_timestamp


def success_response(data: Any = None, message: str = "成功") -> Dict[str, Any]:
    """
    返回成功响应
    
    Args:
        data: 返回的数据
        message: 提示消息
    
    Returns:
        Dict[str, Any]: 成功响应
    """
    return {
        "code": 200,
        "data": data,
        "message": message,
        "timestamp": get_current_timestamp()
    }


def error_response(code: int = 400, message: str = "失败", data: Any = None) -> Dict[str, Any]:
    """
    返回错误响应
    
    Args:
        code: 错误代码
        message: 错误消息
        data: 附加数据
    
    Returns:
        Dict[str, Any]: 错误响应
    """
    return {
        "code": code,
        "data": data,
        "message": message,
        "timestamp": get_current_timestamp()
    }


def pagination_response(data: Any, total: int, message: str = "成功") -> Dict[str, Any]:
    """
    返回分页数据响应
    
    Args:
        data: 分页数据
        total: 总记录数
        message: 提示消息
    
    Returns:
        Dict[str, Any]: 分页响应
    """
    return {
        "code": 200,
        "data": data,
        "total": total,
        "message": message,
        "timestamp": get_current_timestamp()
    }